
<template>
  <div>
    <el-steps :active="1"  style="width:70%;margin-left:100px" >
      <el-step
        title="试卷基本信息"
       
      ></el-step>
      <el-step
        title="添加试题"
       
      ></el-step>
     <el-step
        title="完成添加"
       
      ></el-step>
    </el-steps>
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="250px"
      class="demo-ruleForm"
    >
      <el-form-item label="试卷分类名称:" prop="papercategory">
        <el-select
          v-model="ruleForm.papercategory"
          placeholder="语文考试/期末考试试卷"
        >
          <el-option label="语文试卷" value=1 ></el-option>
          <el-option label="数学试卷" value=2></el-option>
          <el-option label="英语试卷" value=3></el-option>
          <el-option label="化学试卷" value=4></el-option>
          <el-option label="物理试卷" value=5></el-option>
          <el-option label="生物试卷" value=6></el-option>
          
        </el-select>
      </el-form-item>
      <el-form-item label="试卷名称:" prop="name">
        <el-input v-model="ruleForm.name" style="width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="试卷类型:" prop="type">
        <el-radio-group v-model="ruleForm.type">
          <el-radio label="固定试题"></el-radio>
          <el-radio label="随机试题"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="试卷难度:" prop="difficulty">
        <el-radio-group v-model="ruleForm.difficulty">
          <el-radio label="容易"></el-radio>
          <el-radio label="一般"></el-radio>
          <el-radio label="困难"></el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="试卷说明" prop="note">
        <el-input
          type="textarea"
          v-model="ruleForm.note"
          style="width: 500px"
          rows="5"
          placeholder="请输入备注信息"
        ></el-input>
      </el-form-item>
      <el-form-item>
        
        <el-button @click="resetForm('ruleForm')">重置</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >下一步</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>
<script >
export default {
  data() {
    return {
      ruleForm: {
        papercategory:"",

        name: "",
        type:"",
        difficulty:"",
        note:"",
        region: "",
        resource1:"",
        resource:"",
         token: localStorage.getItem("logintoken"),
       
      },
      rules: {
        name: [
          { required: true, message: "请输入试卷名称", trigger: "blur" },
          { min: 3, max: 10, message: "长度在 3 到 10 个字符", trigger: "blur" },
        ],
        papercategory: [
          { required: true, message: "请选择试卷类型", trigger: "change" },
        ],
        
        
      },
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
          //跳转下一个页面
          console.log(this.ruleForm);
           this.$axios.post(`/api/paperManager/paper`,this.ruleForm).then(res=>{
             if(res.data.code==200){
               this.$router.push({path: '/addQuesstion' })
             }
               
                
              }).catch(error => {})
          //
          //非空校验
        // if (valid) {
        //   alert("submit!");
        // } else {
        //   console.log("error submit!!");
        //   return false;
        // }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>